package org.mcf.DaoImpl;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import org.apache.commons.dbutils.handlers.MapListHandler;
import org.diyi.Tools.BaseDao;
import org.mcf.Dao.CollectionDao;

public class CollectionDaoImpl extends BaseDao implements CollectionDao{

	@Override
	public List<Map<String, Object>> selectColl(int id) {
	String sql="select c.userid,p.*,i.imgid from collection c,product p,image i where c.productid=p.productid and p.imgid=i.id and c.userid=?";
		try {
			return query.query(sql, new MapListHandler(),id);
		} catch (SQLException e) {
			
			e.printStackTrace();
		}
		return null;
	}

	@Override
	public Integer insertCollection(int id, int userid) {
		String sql="insert into collection(productid,userid) VALUES(?,?)";
		try {
			return query.update(sql,id,userid);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return -1;
	}
		
}
